package com.wangy.service.impl;


import com.wangy.mapper.UserRoleMapper;
import com.wangy.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * *@Author yyzb
 * *@Date 2024/10/23 17:53
 * *@Version 1.0
 */

@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public Long getRoleIdByUserId(Long userId) {
        return userRoleMapper.getRoleIdByUserId(userId);
    }

    // 先删除用户对应的角色再添加
    @Override
    public void addUserIdRoleIdRelationship(Long userId, Long roleId) {
        userRoleMapper.deleteByUserId(userId);
        userRoleMapper.addUserIdRoleIdRelationship(userId, roleId);
    }
}
